package org.snaker.engine.parser.logicflow.node;


import org.snaker.engine.model.CustomModel;
import org.snaker.engine.model.NodeModel;
import org.snaker.engine.parser.logicflow.LogicFlowJSONAbstractNodeParser;
import org.snaker.engine.parser.logicflow.model.LogicFlowData;


/**
 * 自定义节点解析类
 * @author mldong
 * @date 2023/12/7
 */
public class CustomParser extends LogicFlowJSONAbstractNodeParser {


    @Override
    protected void parseNode(NodeModel model, LogicFlowData.Node node) {
        CustomModel customModel = (CustomModel) nodeModel;
        LogicFlowData.Properties properties = node.getProperties();
        customModel.setClazz(properties.get(ATTR_CLAZZ));
        customModel.setMethodName(properties.get(ATTR_METHODNAME));
        customModel.setArgs(properties.get(ATTR_ARGS));
        customModel.setVar(properties.get(ATTR_VAR));
    }

    @Override
    public NodeModel newModel() {
        return new CustomModel();
    }
}
